package com.prototype.deepclone;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/4/13 15:10
 */
public class Client {

    public static void main(String[] args) {
        DeepProtoType d = new DeepProtoType();
        d.name = "songjiang";
        d.deepCloneableTarget = new DeepCloneableTarget("牛马", "牛类");
        
        // 方式一 完成深拷贝
        /*try {
            DeepProtoType d2 = (DeepProtoType) d.clone();
            System.out.println("d.name = " + d.name + "d.DeepCloneableTarget = " + d.deepCloneableTarget.hashCode());
            System.out.println("d2.name = " + d2.name + "d2.DeepCloneableTarget = " + d2.deepCloneableTarget.hashCode());
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }*/
        
        
        
        // 方式二 完成深拷贝
        try {
            DeepProtoType d2 = (DeepProtoType) d.deepClone();
            System.out.println("d.name = " + d.name + "d.DeepCloneableTarget = " + d.deepCloneableTarget.hashCode());
            System.out.println("d2.name = " + d2.name + "d2.DeepCloneableTarget = " + d2.deepCloneableTarget.hashCode());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        
    }
    
}
